var app_scheme = document.getElementById('app_scheme').value
var bg_type = document.getElementById('bg_type').value
var icon = document.getElementById('icon').value

iframe = document.createElement('iframe');
iframe.style.cssText = 'display:none;width=0;height=0';
var timer = null;
var body = document.body;
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// identity function for calling harmony imports with the correct context
/******/ 	__webpack_require__.i = function(value) { return value; };
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, {
/******/ 				configurable: false,
/******/ 				enumerable: true,
/******/ 				get: getter
/******/ 			});
/******/ 		}
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

var Root = React.createClass({
    displayName: 'Root',

    getInitialState: function getInitialState() {
        return {
            isiOS: false,
            isAndroid: false,
            mask: false
        };
    },
    showDownload: function showDownload() {
        var ua = window.navigator.userAgent.toLowerCase();
        // iOS/android
        if (/(iPhone|iPad|iPod|iOS)/i.test(ua)) {
            this.state.isiOS = true;
        } else {
            this.state.isAndroid = true;
        }
        // 微信/支付宝扫码
        if (/(MicroMessenger|AlipayClient)/i.test(ua)) {
            var _mask = this.state.mask;
            this.setState({
                mask: !_mask
            });
        } else {
            if (this.state.isiOS) {
              body.appendChild(iframe);
              iframe.src = app_scheme;
              var t = Date.now();
              timer = setTimeout(function() {
                  if (Date.now() - t > 1200) {
                      clearTimeout(timer);
                      return false;
                  }
                  if (document.webkitHidden || document.hidden) {
                      return false;
                  }
                  var ios_url = document.getElementById('ios_url').value
                  var app_name = document.getElementById('app_name').value
                  if (ios_url.length > 5) {
                    window.location.href = ios_url;
                  }else{
                    alert(app_name+' iOS版即将上线');
                  }
              }, 500);
            } else {
              body.appendChild(iframe);
              iframe.src = app_scheme;
              var t = Date.now();
              timer = setTimeout(function() {
                  if (Date.now() - t > 1200) {
                      clearTimeout(timer);
                      return false;
                  }
                  if (document.webkitHidden || document.hidden) {
                      return false;
                  }
                  var android_url = document.getElementById('android_url').value
                  var app_name = document.getElementById('app_name').value
                  if (android_url.length > 5) {
                    window.location.href = android_url;
                  }else{
                    alert(app_name+' Android版即将上线');
                  }
              }, 500);
            }
        }
    },
    hideMask: function hideMask() {
        var _mask = this.state.mask;
        this.setState({
            mask: !_mask
        });
    },
    componentDidMount: function componentDidMount() {
        var _this = this;
        var ua = window.navigator.userAgent.toLowerCase();
        // 微信打开
        if (/(MicroMessenger|AlipayClient)/i.test(ua)) {
            _this.showDownload();
            return;
        }
        if (/(iPhone|iPad|iPod|iOS)/i.test(ua)) {
          body.appendChild(iframe);
          iframe.src = app_scheme;
          var t = Date.now();
          timer = setTimeout(function() {
              if (Date.now() - t > 1200) {
                  clearTimeout(timer);
                  return false;
              }
              if (document.webkitHidden || document.hidden) {
                  return false;
              }
			var ios_url = document.getElementById('ios_url').value
                  var app_name = document.getElementById('app_name').value
                  if (ios_url.length > 5) {
                    window.location.href = ios_url;
                  }else{
                    alert(app_name+' iOS版即将上线');
                  }
          }, 1000);
        } else {
          body.appendChild(iframe);
          iframe.src = app_scheme;
          var t = Date.now();
          timer = setTimeout(function() {
              if (Date.now() - t > 1200) {
                  clearTimeout(timer);
                  return false;
              }
              if (document.webkitHidden || document.hidden) {
                  return false;
              }
            var android_url = document.getElementById('android_url').value
                  var app_name = document.getElementById('app_name').value
                  if (android_url.length > 5) {
                    window.location.href = android_url;
                  }else{
                    alert(app_name+' Android版即将上线');
                  }
          }, 1000);
        }
    },
    render: function render() {
        var app_name = document.getElementById('app_name').value
        return React.createElement(
            'div',
            { className: 'app_show' },
            React.createElement(
                'div',
                { className: 'app_icon' },
                React.createElement(
                    'img',
                    { src: icon, className: 'icon_img' }
                ),
                React.createElement(
                    'div',
                    { className: 'app_title' },
                    app_name
                )
            ),
            React.createElement(
                'div',
                { className: 'download' },
                React.createElement(
                    'a',
                    { href: 'javascript:void(0)', onClick: this.showDownload, className: 'btn btn-download' },
                    '\u7ACB\u5373\u4E0B\u8F7DAPP'
                ),
                React.createElement(
                    'div',
                    { className: this.state.mask ? this.state.isiOS ? 'fixed ios fadeIn' : 'fixed android fadeIn' : '', onClick: this.hideMask },
                    React.createElement('div', { className: 'tip-bg' })
                )
            )
        );
        // return React.createElement(
        //     'div',
        //     { className: 'download' },
        //     React.createElement(
        //         'a',
        //         { href: 'javascript:void(0)', onClick: this.showDownload, className: 'btn btn-download' },
        //         '\u7ACB\u5373\u4E0B\u8F7DAPP'
        //     ),
        //     React.createElement(
        //         'div',
        //         { className: this.state.mask ? this.state.isiOS ? 'fixed ios fadeIn' : 'fixed android fadeIn' : '', onClick: this.hideMask },
        //         React.createElement('div', { className: 'tip-bg' })
        //     )
        // );
    }
    // render: function render() {
    //     return React.createElement(
    //         'div',
    //         { className: 'download' },
    //         React.createElement(
    //             'a',
    //             { href: 'javascript:void(0)', onClick: this.showDownload, className: 'btn btn-download' },
    //             '\u7ACB\u5373\u4E0B\u8F7DAPP'
    //         ),
    //         React.createElement(
    //             'div',
    //             { className: this.state.mask ? this.state.isiOS ? 'fixed ios fadeIn' : 'fixed android fadeIn' : '', onClick: this.hideMask },
    //             React.createElement('div', { className: 'tip-bg' })
    //         )
    //     );
    // }
});
ReactDOM.render(React.createElement(Root, null), document.getElementById('main'));

/***/ })
/******/ ]);